package dao;


import java.util.ArrayList;
import java.util.List;

import entity.loginentity;

public class loginentityDao extends BaseDao{
	
	/**
	 * 登陆
	 * @param phone
	 * @param userPassword
	 * @return
	 */
	public int cha(String phone,String userPassword){
		try {
			rs=executeQuery("select count(1),userId from user where phone=? and userPassword=?", phone,userPassword);
		if(rs.next()){
			return rs.getInt(1);
		}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return 0;
	}
	/**
	 * 获取用户信息
	 * @param phone
	 * @param userPassword
	 * @return
	 */
	public List<loginentity> userid(String phone,String userPassword){
		try {
			List<loginentity> log=new ArrayList<loginentity>();
			rs=executeQuery("select * from user where phone=? and userPassword=?", phone,userPassword);
		while(rs.next()){
			loginentity lo=new loginentity();
			lo.setUserId(rs.getInt("userId"));
			lo.setAvater(rs.getString("avater"));
			lo.setBirthday(rs.getDate("birthday"));
			lo.setEmail(rs.getString("email"));
			lo.setIncidentTime(rs.getDate("incidentTime"));
			lo.setPhone(rs.getString("phone"));
			lo.setSex(rs.getString("sex"));
			lo.setUserName(rs.getString("userName"));
			lo.setUserPassword(rs.getString("userPassword"));
			log.add(lo);
		}
		return log;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
}
